package com.mhy.wxrobot.message;

import android.text.TextUtils;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class ImageMessage implements Message {

    private String base64;
    private String md5;

    public ImageMessage(String base64,String md5) {
        this.base64 = base64;
        this.md5 = md5;
    }

	public String toJsonString() {
        Map<String, Object> items = new HashMap<String, Object>();
        items.put("msgtype", "image");

        Map<String, Object> textContent = new HashMap<String, Object>();
        if (TextUtils.isEmpty(base64)) {
            throw new IllegalArgumentException("base64 should not be Empty");
        }
        textContent.put("base64", base64);
        textContent.put("md5", md5);
        items.put("image", textContent);
        return new JSONObject(items).toString();
    }
}
